import re
import numpy as np
import matplotlib.pyplot as plt
pattern = re.compile(r'\&(.+?)\^')
x=[]
y=[]
x2=np.linspace(0, 300, 100)
y2=-x2+100#直线
with open('data2.txt','r',encoding='utf-8') as f:
    for  i in f.readlines():
        str=pattern.findall(i.strip())
        for j in range(0,len(str)-1):
            if str[j].isnumeric() and str[j+1].isnumeric():
                if int(str[j])<300 and int(str[j+1])<3000: #范围
                    x.append(int(str[j]))
                    y.append(int(str[j+1]))
                if int(str[j+1])>-2*int(str[j])+100:#函数关系
                    print(i)
                break

plt.scatter(x,y,s=1)
plt.plot(x2,y2,color="red",linestyle="--", linewidth=1)
plt.show()